<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.hzqy.commons.utils.ConstantUtils" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>天气预报列表</title>
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/defalut.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/public.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/ddspstyle.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/icon.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/WdatePicker/skin/WdatePicker.css">
<script type="text/javascript" src="../../static/js/jquery.min.js"></script>
<script type="text/javascript" src="../../static/js/jquery.easyui.min.js"></script>
<script type="text/javascript"	src="../../static/js/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../../static/js/jquery.validate.js"></script>
<script type="text/javascript" src="../../static/js/index.js"></script>
<script type="text/javascript" src="../../static/js/WdatePicker/WdatePicker.js"></script>
<script type="text/javascript" charset="utf-8" src="../../ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="../../ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" charset="utf-8" src="../../ueditor/lang/zh-cn/zh-cn.js"></script>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<%
String []nonceObj=ConstantUtils.getNonceObject();
%>
<script type="text/javascript">
	document.onkeydown = function(event) {
		var e = event || window.event || arguments.callee.caller.arguments[0];
		if (e && e.keyCode == 13) { // enter 键
			try {
				searchData();
			} catch (e) {
				gotoSearch($('#easyui-treegrid'));
			}
		}
	};
</script>
<style type="text/css">
.imgsw {
	background: url(../resource/images/a0133.png) no-repeat;
	height: 14px;
	width: 17px;
	display: inline-block;
	border: 0;
}
</style>
<script type="text/javascript">
		var queryParams;
		function EasyuiDatagrid(){
			$("#easyui-datagrid").datagrid({
				url: '../../weather_forecast/weather_list.do',
				nowrap: true,
				striped: true,
				border: false,
				fit: true,
				rownumbers:true,
				queryParams: getGueryParams(),
				columns: [[
					{field:'id',checkbox:true},
					{field:'f_wf_id',title:'ID',align:'center',width:50},
					{field:'f_wf_userarea_name',title:'地区',align:'center',width:100},
					/* {field:'f_wf_city',title:'城市',align:'center',width:100},
					,formatter:function(value,row,index){
						console.log("value="+value);
						if(value == undefined || value == ""){
							return "";
						}else{
							var areaArr = value.split("-");
							return provice[areaArr[0]].city[areaArr[1]].districtAndCounty[areaArr[2]];
						}
					} */
					{field:'f_wf_minTemperature',title:'最低气温/℃',align:'center',width:80},
					{field:'f_wf_maxTemperature',title:'最高气温/℃',align:'center',width:80},
					{field:'f_wf_weather',title:'天气状况',align:'center',width:150},
					{field:'f_wf_date',title:'天气时间',align:'center',width:150,
						formatter:function(value,row,index) {
							if(value!=null){
								var date = "";
								var arr = new Array();
								arr = value.split(".");
								if(arr.length > 1){
									date = arr[0];
								}
								return date;
							}
						}},
					{field:'f_wf_cdate',title:'创建时间',align:'center',width:150,
						formatter:function(value,row,index) {
							if(value!=null){
								var date = "";
								var arr = new Array();
								arr = value.split(".");
								if(arr.length > 1){
									date = arr[0];
								}
								return date;
							}
						}},
					{field:'f_wf_udate',title:'更新时间',align:'center',width:150,
						formatter:function(value,row,index) {
							if(value!=null){
								var date = "";
								var arr = new Array();
								arr = value.split(".");
								if(arr.length > 1){
									date = arr[0];
								}
								return date;
							}
						}},
					{field:'_parentId',title:'操作',align:'center',width:180,
						formatter:function(value,row,index){
							str= '<a id="info" class="easyui-linkbutton l-btn l-btn-plain" plain="true" iconcls="icon-edit" href="javascript:void(0);" onclick="info(\''+row.f_wf_id+'\');"><span class="l-btn-left"><span class="l-btn-text icon-edit l-btn-icon-left">详情</span></span></a>';
							str+= '<a id="edit" class="easyui-linkbutton l-btn l-btn-plain" plain="true" iconcls="icon-edit" href="javascript:void(0);" onclick="edit(\''+row.f_wf_id+'\');"><span class="l-btn-left"><span class="l-btn-text icon-edit l-btn-icon-left">修改</span></span></a>';
							str+='<a id="delete" class="easyui-linkbutton l-btn l-btn-plain" plain="true" iconcls="icon-remove" onclick="deleteWeather(\''+ row.f_wf_id+ '\');"><span class="l-btn-left"><span class="l-btn-text icon-remove l-btn-icon-left">删除</span></span></a>';
							return str;
				    	}
					}
				]],
				singleSelect:true,
				pagination: true,
				pageList: [10,20,30,40,50],
				pageSize:10,
				toolbar: '#toolbar',
				onExpandRow: function(index,row){
				
				},
				onSelect: function(rowIndex,rowData) {
					
				},
				onUnselect: function(rowIndex,rowData) {
					
				},
				onCheckAll: function(rowIndex,rowData) {
					
				},
				onUncheckAll: function(rowIndex,rowData) {
				
				},
				onLoadSuccess: function (data) {
					if(data.total==-1) {
						$.messager.defaults={ok:"确定",cancel:"取消"};
						$.messager.confirm('提示', '用户尚未登录,请登录', function(r){
							if (r){
							    window.parent.location.href='/cbweb';
							    return false;
							}
						});
					}
				}
			});
	    }
		function getGueryParams(){
			/* $("#f_wf_cityid").val(getAddress()); */
			return {
				/* f_wf_cityid:$("#f_wf_cityid").val(), */
				f_wf_userarea:$("#f_wf_userarea").val(),
				f_wf_startTime:$("#f_wf_startTime").val(),
				f_wf_endTime:$("#f_wf_endTime").val()
			};
		}
		$(function(){
			$.ajax({
				url:"../../statistics/area_tree.do?f_sa_id=0",
				success:function(data) {
					data = JSON.parse(data);
					var str = "";
					for(var i=0;i<data.length;i++) {
						str+='<option value="'+data[i].id+'">'+data[i].name+'</option>';
					}
					$("#f_wf_userarea").append(str);
				}
			});
			/* $("#prov").val(11);
			$("#city").val(0);
			showCountry(city); */
			new EasyuiDatagrid();
			gotoSearch = function(){
				$("#easyui-datagrid").datagrid('reload',getGueryParams());
			};
		});
		
		function load(){
			$(".datagrid-row-expander datagrid-row-expand").attr("display","none"); 
			 $(".datebox :text").attr("readonly","readonly");
		}
		
		function onpress(){
		var event=arguments.callee.caller.arguments[0]||window.event;//消除浏览器差异
   		  	if (event.keyCode == 13){  
      			gotoSearch($('#easyui-treegrid'));
    		}
		}
		function add(){
			openDialog($("#dlg"),'weather_add.jsp');
		}
	
		function info(f_wf_id){
			openDialog($("#dlg"),'weather_info.jsp?f_wf_id='+f_wf_id);
		}
		function edit(f_wf_id){
			openDialog($("#dlg"),'weather_update.jsp?f_wf_id='+f_wf_id);
		}
		
		function deleteWeather(f_wf_id){
			$.messager.confirm('确认删除记录','确认删除信息么？',function(r) {
					if (r) {
						$.ajax({
							type : "POST",
							url : '../../weather_forecast/delete_weather.do?f_wf_id='+ f_wf_id+'&stime=<%=nonceObj[0]%>&sign=<%=nonceObj[1]%>',
							dataType : "json",
							success : function(result) {
								if (result.success == true) {
									alert( "删除成功!");
									if (checkAjaxRequestValidity(result)) {
										gotoSearch($('#easyui-treegrid'));
									}
								} else {
									alert("删除失败!");
								}
								window.location.reload();
							},
							error : function(result) {
								alert("删除异常，请联系管理员");
								if ($.isFunction(window.showMessager)) {
									window.showMessager(result.resultTitle,result.result);
								}
							}
						});
					}
			});
		}
		function getAddress(){
			var prov = $("#prov").val();
			var city = $("#city").val();
			var country = $("#country").val();
			var str="";
			if(city == ""){
				str = "";
				//str = prov+"-";
			}else if(country == ""){
				str = "";
				//str = prov+"-"+city+"-";
			}else {
				str = prov+"-"+city+"-"+country;
			}
			return str;
		}
	</script>
  </head>
  <body onload="load();">
	<table id="easyui-datagrid" title="天气预报管理"></table>
	<div id="toolbar" class="easyui_datagrid_toolbar" style="">
		<div class="easyuiSearch">
			<form onsubmit="return false;" method="post">
				<table cellspacing="0" cellpadding="0" width="90%">
					<tr>
						<!-- <td align="right" width="5%">城市：</td>
						<td align="left" width="35%">
							<select id="prov" onfocus="this.defaultIndex=this.selectedIndedx;" onchange="this.selectedIndex=this.defaultIndex;" style="width: 80px;">
								                <option value="11">浙江省</option>
							</select>
							<select id="city" name="city" onchange="showCountry(this)" style="width: 80px;">
												<option value="">请选择</option>
							</select> 
							<select id="country" style="width: 80px;">
												<option value="">请选择</option>
							</select>
							<input name="f_wf_cityid" id="f_wf_cityid" type="hidden" onkeydown="onpress();" />
						</td> -->
						
						<td align="right" width="10%">天气时间：</td>
						<td align="left" width="35%">
							<input onClick="WdatePicker()" id="f_wf_startTime" name="f_wf_startTime" style="width: 100px;" onkeydown="onpress();" /> 
							--<input onClick="WdatePicker()" id="f_wf_endTime" name="f_wf_endTime" style="width: 100px;" onkeydown="onpress();" />
						
						<!-- 	<input id="f_wf_date" name="f_wf_date" type="text" onClick="WdatePicker({skin:'default',dateFmt: 'yyyy-MM-dd HH:mm:ss'})" onkeydown="onpress();" style="width: 100px;"  value="" class="yl_inp yw_name" />	
						 --></td>
						<td align="left" width="15%">地区：</td>
						<td>
						    <select id="f_wf_userarea" name="f_wf_userarea">
								<option value="0">--请选择--</option>
							</select>
						</td>
					</tr>
					<tr>
						<td align="left" width="10%">
								<a href="javascript:void(0);" class="easyui-linkbutton"
									data-options="iconCls:'icon-add', plain:true" onclick="add()">增加</a>
						</td>
						<td colspan="6" align="left"><a href="javascript:void(0);" class="easyui-linkbutton"
							data-options="iconCls:'icon-search', plain:true"
							onclick="gotoSearch($('#easyui-datagrid'))">查询</a> 
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>


	<div id="dlg" class="easyui-dialog" style="width: 900px; height: 700px; padding-top: 0px;"
		data-options="title: '天气预报', iconCls:'icon-save',modal:true,closed:true,buttons:'#dlg_buttons'">
		<iframe scrolling="auto" frameborder="0" style="width: 100%; height: 99%;"></iframe>
	</div>
	</body>
	<!-- <script type="text/javascript" src="../../static/js/city/city.js"></script>
<script type="text/javascript" src="../../static/js/city/method01.js"></script> -->
</html>